<html layout:decorate="~{project/paramSettingManage/target_list}" xmlns:layout="http://www.w3.org/1999/xhtml">
<div layout:fragment="content_list">

    <div class="main-body">

        <div id="toolbar" class="btn-group btn-group-sm " style="display: none;">

            <!--<a type="button" href="/project/indexManage/index_importData" class="btn btn-success" data-toggle="modal"-->
            <!--data-target="#modal">导入数据</a>-->
            
        </div>

        <div class="modal-header">
            <h4 class="modal-title">修改参数</h4>
        </div>
        <form id="defaultForm" method="post" class="form-horizontal" action="/project/paramSettingManage/param_save">
            <div class="modal-body">
                <div th:each=" pmap: ${pMaps}" >
                    <div th:if="${pmap.key == 'A等级因子'}" >
                        <div class="form-group">
                            <label class=" col-lg-2 col-lg-offset-1 control-label">A等级因子(数字)</label>
                        </div>
                        <div th:each="paramSetting:${pmap.value}" class="form-group">
                            <label class="col-lg-2 col-lg-offset-1 control-label" th:text="${paramSetting.key}"></label>
                            <input class="col-lg-3" type="text" th:name="${'ID_'+paramSetting.id}" th:value="${paramSetting.value}"/>
                        </div>
                    </div>
                </div>

                <div th:each=" pmap: ${pMaps}" >
                    <div th:if="${pmap.key == 'B时效因子'}">
                        <div class="form-group">
                            <label class=" col-lg-2 col-lg-offset-1 control-label">B时效因子</label>
                        </div>
                        <div th:each="paramSetting:${pmap.value}" class="form-group">
                            <input class="col-lg-2 col-lg-offset-1 control-label" type="text" th:name="${'KEY_'+paramSetting.id}" th:value="${paramSetting.key}"/>
                            <input class="col-lg-3" type="text" th:name="${'ID_'+paramSetting.id}" th:value="${paramSetting.value}"/>
                        </div>
                    </div>
                </div>
                <div th:each=" pmap: ${pMaps}" >
                    <div th:if="${pmap.key == '需求积分'}">
                        <div th:each="paramSetting:${pmap.value}" class="form-group">
                            <label class="col-lg-2 control-label" th:text="${paramSetting.key}"></label>
                            <input class="col-lg-3" type="text" th:name="${'ID_'+paramSetting.id}" th:value="${paramSetting.value}"/>
                        </div>
                    </div>
                </div>
                <div th:each=" pmap: ${pMaps}" >
                    <div th:if="${pmap.key == '客户来源'}">
                        <div th:each="paramSetting:${pmap.value}" class="form-group">
                            <label class="col-lg-2 control-label" th:text="${paramSetting.key}"></label>
                            <input class="col-lg-3" type="text" th:name="${'ID_'+paramSetting.id}" th:value="${paramSetting.value}"/>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-lg-offset-3">
                <button type="submit" class="btn btn-primary">保存</button>
            </div>
        </form>
        <div style="
            background: #fff;
            height: 20px;
            margin-top: 10px;">
        </div>
        <div class="modal-header">
            <h4 class="modal-title">车型数据上传</h4><a name="uploadFile"></a>
        </div>
        <form id="form2" method="post" class="form-horizontal" enctype="multipart/form-data" action="/project/paramSettingManage/brandMaker_save#uploadFile">
            <div class="modal-body">
                <div class="form-group">
                    <div class=" col-lg-offset-1 col-lg-6">
                        车型数据库：<font color="red">（直接按照数据库格式上传 Excel 表，排序即按照上传的表格顺序，上传后整体替换）</font>
                        <br/>
                        <br/>
                        <input type="file" name="fileName" id="id-input-file">  
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-lg-offset-1 col-lg-10" th:if="${importDataMsg !='' }" th:text="${importDataMsg}">
                    </div>
                </div>
            </div>
            <div class="col-lg-offset-1">
                <button type="submit" class="btn btn-primary" style="margin-left: 15px;">保存</button>
            </div>
            <div class="space-16"></div>
        </form>

        <script>
            $('#id-input-file').ace_file_input({
                no_file:'未选择任何文件',
                btn_choose:'选择',
                btn_change:'更改',
                droppable:false,
                onchange:null,
                thumbnail:false //| true | large
                //whitelist:'gif|png|jpg|jpeg'
                //blacklist:'exe|php'
                //onchange:''
                //
			});

            function loadFile(file){
                $("#filename").val(file.name);
            }

            initCheck();
            //初始化表单验证
            function initCheck() {
                $('#defaultForm')
                    .bootstrapValidator({
                    })
                    .on('success.form.bv', function (e) {
                        // 阻止默认提交事件
                        e.preventDefault();
                        // 获取form表单
                        var $form = $(e.target);
                        // Get the BootstrapValidator instance
                        var bv = $form.data('bootstrapValidator');
                        console.log($('#defaultForm').serialize());
                        $.post($form.attr('action'), $form.serialize(), function(result) {
                            console.log(result);
                            var data = eval('('+result+')');
                            if (data.type == "alert") {
                                alert(data.message);
                            }
                            $('#defaultForm').prev().find("button").click();
                            $("#dataTable").bootstrapTable("selectPage",1);
                        }, 'text');
                    });
            }

        </script>
    </div>
</div>
</html>

